load(":pkg.bzl", "pkg_tar")
load(":build.bzl", "release_filegroup")
load("@subpar//:subpar.bzl", "par_binary")

par_binary(
    name = "gcs_uploader",
    srcs = [
        "gcs_uploader.py",
    ],
    python_version = "PY2",
    visibility = ["//visibility:public"],
)

pkg_tar(
    name = "pkg_tar_smoke",
    srcs = glob(["*.bzl"]),
)

# generate the hash files to use in the sh_tests below
release_filegroup(
    name = "testfile",
    testonly = True,
    srcs = [":testdata/testfile.txt"],
)

[
    sh_test(
        name = "test_gen%ssum" % hash,
        srcs = ["diff_test.sh"],
        args = [
            "$(location testdata/testfile.txt.%s.expected)" % hash,
            "$(location testdata/testfile.txt.%s)" % hash,
        ],
        data = [
            ":testdata/testfile.txt.%s" % hash,
            ":testdata/testfile.txt.%s.expected" % hash,
        ],
    )
    for hash in [
        "md5",
        "sha1",
        "sha512",
    ]
]

filegroup(
    name = "package-srcs",
    srcs = glob(["**"]),
    tags = ["automanaged"],
    visibility = ["//visibility:private"],
)

filegroup(
    name = "all-srcs",
    srcs = [
        ":package-srcs",
        "//defs/testgen:all-srcs",
        "//defs/testpkg:all-srcs",
    ],
    tags = ["automanaged"],
    visibility = ["//visibility:public"],
)
